package com.maven.demo.dao;

import java.sql.SQLException;
import java.util.List;
import javax.sql.DataSource;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.maven.demo.model.Student;

@Component
public class StudentDao {
	@Autowired  
	private DataSource dataSource;
	
	public List<Student> getStudent() throws SQLException{
    	QueryRunner queryRunner = new QueryRunner(dataSource);  
	    List<Student> pset;
		pset = (List<Student>) queryRunner.query( "SELECT * FROM student", new BeanListHandler<Student>(Student.class));
        return pset;
	} 
}
